﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebForm
{
    public partial class Default : System.Web.UI.Page
    {
        List<Library.BIZ.SanPhamBIZ> listsp;

        protected void Page_Load(object sender, EventArgs e)
        {

            label1.Text = "";
            if (Request.QueryString["keyword"] != null && Request.QueryString["keyword"].Trim() != "")
            {
                listsp = Library.DAL.SanPhamDAL.FindAll(null, Request.QueryString["keyword"].Trim());
            }
            else if (Request.QueryString["gia1"] != null && Request.QueryString["gia2"] != null)
            {
                long gia1 = -1;
                long gia2 = -1;
                if (Request.QueryString["gia1"] != "")
                {
                    long.TryParse(Request.QueryString["gia1"], out gia1);
                }
                if (Request.QueryString["gia2"] != "")
                {
                    long.TryParse(Request.QueryString["gia2"], out gia2);
                }
                listsp = Library.DAL.SanPhamDAL.FindAll(gia1, gia2);

            }
            else
            {
                listsp = Library.DAL.SanPhamDAL.FindAll(null, null);
            }

            foreach (Library.BIZ.SanPhamBIZ s in listsp)
            {
                label1.Text += "<a href='SanPham.aspx?id=" + s.ID + "'>";
                label1.Text += "<div class='element sales da-thumbs item' data-category='sales'>";
                label1.Text += "<div class='product-thumb-hover'>";
                label1.Text += "<section>";
                label1.Text += "<img src='Content/img/upload/" + s.HinhAnh + "' alt=''>";
                label1.Text += "<p class='sale'>Sale</p>";
                label1.Text += "<h3>" + s.TenSP + "</h3>";
                label1.Text += "</article>";
                label1.Text += "</section>";
                label1.Text += "</div>";
                label1.Text += "<section class='right'>";
                label1.Text += "<h3>" + s.TenSP + "</h3>";
                label1.Text += "<span class='price'>" + s.Gia + " đ</span>";
                label1.Text += "</section>";
                label1.Text += "</div>";
                label1.Text += "</a>";
            }
                            
        }
    }
}